class ListNode {
      int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 }
public class LC_206 {
    public ListNode reverseList(ListNode head) {
        if(head == null|| head.next == null) return head;
        ListNode slow = new ListNode(-5001);
        ListNode mid = head;
        ListNode fast = head.next;
        while(mid != null){
            mid.next = slow;
            if(slow.val == -5001){
                mid.next = null;
            }
            slow = mid;
            mid = fast;
            if(fast != null){
                fast = fast.next;
            }
        }
        return slow;
    }
}
